﻿using EventAggregationModule;
using EventAggregationModule.Models;
using Microsoft.Practices.Prism.PubSubEvents;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Product_1
{
    public class IproductPresenter
    {
        private IProduct_1_View _view;
        private IEventAggregator eventAggregator;

        public IproductPresenter(IEventAggregator eventAggregator)
        {
            this.eventAggregator = eventAggregator;
        }

        void lotnumberResult(object sender, EventArgs e)
        {
            LotNumber lotnumber = new LotNumber();

            lotnumber.lotNumber = View.LotNumber;

            eventAggregator.GetEvent<LotNumberEvent>().Publish(lotnumber);
        }

        public IProduct_1_View View
        {
            get { return _view; }
            set
            {
                _view = value;      //view값 setting
                _view.lotnumberResult += lotnumberResult;       //tightly-coupled
            }
        }
    }
}
